package com.godenwater.core.spring.json;

import java.io.IOException;

import org.codehaus.jackson.JsonGenerator;
import org.codehaus.jackson.JsonProcessingException;
import org.codehaus.jackson.map.JsonSerializer;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.SerializerProvider;

/*
 * JSON对象转换器
 */
public class ObjectMappingCustomer extends ObjectMapper {

	public ObjectMappingCustomer(){
		super();
		//允许单引号
		//this.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true);
		//字段和值都加引号
		//this.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
		//数字也加引号
		//this.configure(JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS, true);
		//空值处理为空串
		
		this.getSerializerProvider().setNullValueSerializer(new JsonSerializer<Object>(){

			@Override
			public void serialize(Object value, JsonGenerator jg,
					SerializerProvider sp) throws IOException,
					JsonProcessingException {
				// TODO Auto-generated method stub
				System.out.println("-------JSON MAPPING------------");
				jg.writeString("");
			}
			
		});
		
		//this.getSerializerProvider().se;
		
	}
	
	
	
}
